package com.yanqu.road.entity.activity.xiuxian.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 凡人修仙房间信息
 */
@FieldTypeAnnotation(tableName = "t_c_xiuxian_pvp_place_data")
public class CrossXiuXianPvpPlaceData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "宝地", update = true)
    private int placeId;

    @FieldTypeAnnotation(desc = "占领的宗门")
    private int campId;

    @FieldTypeAnnotation(desc = "占领时间")
    private long seizeTime;

    @FieldTypeAnnotation(desc = "占领最后产出时间")
    private long lastSeizeRewardTime;

    @FieldTypeAnnotation(desc = "更新时间")
    private long updateTime;

    /**
     * 房间玩家信息
     */
    private Set<Long> userList = new HashSet<>();

    @FieldTypeAnnotation(desc = "宗门占领信息")
    private Map<Integer, CrossXiuXianPvpPlaceSeizeInfo> seizeInfoMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "最后抢占宗门")
    private int lastSeizeCampId;

    @FieldTypeAnnotation(desc = "上次推送持续占领公告时间")
    private long lastNoticeSeizeTime;

    public CrossXiuXianPvpPlaceData() {

    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getPlaceId() {
        return placeId;
    }

    public void setPlaceId(int placeId) {
        if (this.placeId != placeId) {
            this.placeId = placeId;
            setOp(DataStatus.Update);
        }
    }

    public int getCampId() {
        return campId;
    }

    public void setCampId(int campId) {
        if (this.campId != campId) {
            this.campId = campId;
            setOp(DataStatus.Update);
        }
    }

    public long getSeizeTime() {
        return seizeTime;
    }

    public void setSeizeTime(long seizeTime) {
        if (this.seizeTime != seizeTime) {
            this.seizeTime = seizeTime;
            setOp(DataStatus.Update);
        }
    }

    public long getLastSeizeRewardTime() {
        return lastSeizeRewardTime;
    }

    public void setLastSeizeRewardTime(long lastSeizeRewardTime) {
        if (this.lastSeizeRewardTime != lastSeizeRewardTime) {
            this.lastSeizeRewardTime = lastSeizeRewardTime;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, CrossXiuXianPvpPlaceSeizeInfo> getSeizeInfoMap() {
        return seizeInfoMap;
    }

    public void setSeizeInfoMap(Map<Integer, CrossXiuXianPvpPlaceSeizeInfo> seizeInfoMap) {
        this.seizeInfoMap = seizeInfoMap;
        setOp(DataStatus.Update);
    }

    public long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(long updateTime) {
        if (this.updateTime != updateTime) {
            this.updateTime = updateTime;
            setOp(DataStatus.Update);
        }
    }

    public int getLastSeizeCampId() {
        return lastSeizeCampId;
    }

    public void setLastSeizeCampId(int lastSeizeCampId) {
        if (this.lastSeizeCampId != lastSeizeCampId) {
            this.lastSeizeCampId = lastSeizeCampId;
            setOp(DataStatus.Update);
        }
    }

    public long getLastNoticeSeizeTime() {
        return lastNoticeSeizeTime;
    }

    public void setLastNoticeSeizeTime(long lastNoticeSeizeTime) {
        if (this.lastNoticeSeizeTime != lastNoticeSeizeTime) {
            this.lastNoticeSeizeTime = lastNoticeSeizeTime;
            setOp(DataStatus.Update);
        }
    }

    public Set<Long> getUserList() {
        synchronized (this){
            return new HashSet<>(userList);
        }
    }

    public void setUserList(Set<Long> userList) {
        synchronized (this) {
            this.userList = userList;
        }
    }
}
